<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* ****************************************************************************
  NAIYUMIE KING WANG JJANG Front End Developer <naiyumie@gmail.com>
  FileType:CRLF, Encording:UTF-8, Tab&Space:4/4
  ------------------------------------------------------------------------
  TDD
**************************************************************************** */

class Xcli extends CI_Controller {

	# 1) cd D:\_workspace\_php_rubyaura_workspace\rubyaura
	# 2) php index.php Xcli run Money TmpTest
	public function run($originalFileName, $copyFileName){
		$p = 'D:\\_workspace\\_php_rubyaura_workspace\\rubyaura\\application\\';

		$originalFileName ;
		$ofc = sprintf('%scontrollers\\%s.php', $p, $originalFileName);
		$ofm = sprintf('%smodels\\%sM.php', $p, $originalFileName);
		$ofv = sprintf('%sviews\\v%s.php', $p, $originalFileName);

		$copyFileName ;
		$cfc = sprintf('%scontrollers\\%s.php', $p, $copyFileName);
		$cfm = sprintf('%smodels\\%sM.php', $p, $copyFileName);
		$cfv = sprintf('%sviews\\v%s.php', $p, $copyFileName);

		echo
		$originalFileName.PHP_EOL.
		$ofc.PHP_EOL.
		$ofm.PHP_EOL.
		$ofv.PHP_EOL;

		echo
		$copyFileName.PHP_EOL.
		$cfc.PHP_EOL.
		$cfm.PHP_EOL.
		$cfv.PHP_EOL;


		echo copy($ofc,$cfc);
		echo copy($ofm,$cfm);
		echo copy($ofv,$cfv);



	}

/*
	public function run(){
		$ar = array(
			'tagname' => 'tr',
			'childes' => array(
				array('items' => 'td', 'textValue'=>'사과'),
				array('items' => 'td', 'textValue'=>'수박'),
				array('items' => 'td', 'textValue'=>'배'),
				array('items' => 'td', 'textValue'=>'포도'),
				array('items' => 'td', 'textValue'=>'바나나'),
				array('items' => 'td', 'textValue'=>'귤')
			)
		);

//		{ "programmers": [
//  { "firstName": "Brett", "lastName":"McLaughlin", "email": "brett@newInstance.com" },
//  { "firstName": "Jason", "lastName":"Hunter", "email": "jason@servlets.com" },
//  { "firstName": "Elliotte", "lastName":"Harold", "email": "elharo@macfaq.com" }
// ],
//"au

		echo json_encode($ar);
//			echo '	<tr onclick="%s">
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//					<td>%s</td>
//				</tr>';


	}
*/
	public function msg(){
		echo "CLI".PHP_EOL;
		$result = $this->db->query("SELECT * FROM `tbl_local_sidebar`;")->result_array();
		$sep = '/';
		foreach($result as $key=>$val){
			//echo $val['code'] .$sep. $val['names'] .$sep. $val['icons'] .$sep. $val['children_group'] . PHP_EOL ;
			//print_r($val);
			$resultSub = $this->db->query(sprintf("SELECt * FROM tbl_local_sidebar_sub where parent = '%s' order by align asc", $val['children_group']))->result_array();
			$result[$key]['sub'] = $resultSub;
			//print_r($resultSub);
			//foreach($resultSub as $keySub=>$valSub){
			//	echo '>>'.$valSub['uid'] .$sep. $valSub['names'] .$sep. $valSub['parent'] .$sep. $valSub['links1'] .$sep. $valSub['links2'] .$sep. $valSub['querystring'].PHP_EOL;
			//}
		}
		print_r($result);
	}
}